# -*- coding: utf-8 -*-
# Author: xiantingDeng
# Email: dengxianting@shxgroup.net
# Time: 21:19

from common.element.element import Element
from pages.page import demo, excessive


class LoginBiz():
    def __init__(self, driver, log):
        self.__el = Element(driver,log)
        # super().__init__(driver, log)

    def login(self, username, password, text):
        self.__el.click_element(excessive.我的)
        # self.sleep(2)
        # self.__el.click_element(excessive.同意)
        # self.__el.swipe_to_top("left",4)
        # self.__el.click_element(locator=excessive.仅适用期间允许)
        # self.__el.click_element(excessive.始终允许)
        # self.__el.click_element(excessive.我的)
        # self.__el.input_value(demo.账户, username)
        # self.__el.input_value(demo.密码, password)
        # self.__el.click_element(demo.登录)
        # self.__el.screenshot("登录成功截图")
        # if self.__el._find_text_in_page(text):
        #     return True
        # else:
        #     return False


if __name__ == '__main__':

    capabilities = {'platformName': "Android",
                    'platformVersion': "10",
                    'deviceName': "MQS0219927003505",
                    # 'app': app,
                    'clearSystemFiles': True,
                    # 'appActivity': "com.grandale.uo.LaunchActivity",
                    # 'appPackage': "com.grandale.uo",
                    'automationName': 'UIAutomator2',
                    'noSign': True
                    }
    host = "http://localhost:4723/wd/hub"
    from selenium import webdriver

    driver = webdriver.Remote(host, capabilities)
    dict = {"name": "账号", "type": "id", "timeOutInSeconds": 1, "value": "com.grandale.uo:id/login_phone_edt"}
    from common.utils.log_util import logger

    LoginBiz(driver, logger()).login("1554161473", "123456", "登录")
